package paolo.android.worldclock;

import android.content.Context;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase;

class SQLiteHelper extends SQLiteOpenHelper {
	private static final String DATABASE_NAME = "timezones.db";
	private static final int SCHEMA_VERSION = 1;
	
	public SQLiteHelper(Context context) {
		super(context, DATABASE_NAME, null, SCHEMA_VERSION);
	}
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE timezones (_id INTEGER PRIMARY KEY AUTOINCREMENT, tzid TEXT);");
	}
	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		android.util.Log.w("BookLoc", "Upgrading database, which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS timezones");
		onCreate(db);
		
		/* todo: make temp table, copy current data to it, fix real table's schema and then copy the data back */
	}
}

